﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;
using System.Reflection;
using Microsoft.MediaCenter.UI;

namespace Playkanaler
{
    public class Setup : ModelItem
    {
        string us = "";
        public string UpdateStatus
        {
            get
            {
                return us;
            }
            set
            {
                us = value;
                FirePropertyChanged("UpdateStatus");
            }
        }
        void start(string exe, string par)
        {
            System.Diagnostics.ProcessStartInfo  pr = new System.Diagnostics.ProcessStartInfo(exe, par);
            pr.UseShellExecute = false;           
            pr.CreateNoWindow = true;
            System.Diagnostics.Process.Start(pr);

        }
        public void ShowInMenu()
        {
            //try
            //{
            //    Microsoft.MediaCenter.Hosting.ApplicationContext.RegisterApplication(new Uri("file://" + Settings.Path + "Registration.xml"), true, true);
            //    Microsoft.MediaCenter.Hosting.ApplicationContext.RegisterApplication(new Uri("file://" + Settings.Path + "strip.xml"), false, true);

            //}
            //catch (Microsoft.MediaCenter.ApplicationNoPermissionException e)
            //{
                
               
            //    throw;
            //}
            //catch (Microsoft.MediaCenter.ApplicationNotRegisteredException e)
            //{


            //    throw;
            //}



            //start( "c:\\windows\\ehome\\RegisterMCEApp.exe","/allusers " + "\"" +Settings.Path + "Registration.xml\" /u");
            //start(@"regedit","/s " + "\"" +Settings.Path + "strip.reg\"");
            //start("c:\\windows\\ehome\\RegisterMCEApp.exe", "/allusers " + "\"" + Settings.Path + "strip.xml\"");
         

        }
       
       
        public void Update()
        {
           
            Application.DeferredInvokeOnWorkerThread(doupdate, doneupdate, null);
        }

       
        public void HideInMenu()
        {
            //start(@"regedit", "/s " + "\"" + Settings.Path + "stripu.reg\"");
            //start("c:\\windows\\ehome\\RegisterMCEApp.exe", "/allusers " + "\"" + Settings.Path + "strip.xml\" /u");
            //start("c:\\windows\\ehome\\RegisterMCEApp.exe", "/allusers " + "\"" + Settings.Path + "Registration.xml\"");
          
        }
        public void doneupdate(object o)
        {
        }
        public void updatemsg(object o)
        {
            UpdateStatus = o.ToString();
        }


        public void doupdate(object o)
        {

            Application.DeferredInvoke(updatemsg, "...");


        }
    }
}
